Besides the primary string functions we've talked about, there are a few others you should be aware of.
The isxxxx() methods help perform checks on strings.
isalnum() checks if a string is alphanumeric
In [4]:
s = "turtle"
In [5]:
s.isalnum()
Out[5]:
isalnum() checks if a string is alphabetic
In [6]:
s.isalpha()
Out[6]:
In [7]:
y = "turtle3"
y.isalpha()
Out[7]:
islower() checks if string characters are lower
In [8]:
y.islower()
Out[8]:
isupper() for uppercase
In [14]:
y.isupper()
"Wow".isupper()
"WOW".isupper()
Out[14]:
isspace() returns True if a string is all whitespace
In [11]:
" ".isspace()
Out[11]:
In [15]:
"hello".partition("l")
Out[15]:
In [17]:
"hello".split()
Out[17]:
In [19]:
"hello".split("l")
Out[19]: